#include "IntroState.h"
#include "../DeadlyShadowsLastHope/Game.h"
#include <iostream>
using namespace std;
#include "../Abilities/Spin.h"
#include "../Bitmap Font/BitmapFont.h"
#include "MainMenuState.h"

//#include "../gamestate goes here"

CIntroState* CIntroState::GetInstance(void)
{

	static CIntroState s_Instance;
	return &s_Instance;
}

CIntroState::CIntroState()
{
	m_nBackGroundImgID = -1;
}

CIntroState::~CIntroState() { }

void CIntroState::Enter(void)
{
//setup the state
	m_pD3D	= CSGD_Direct3D::GetInstance();
	m_pTM	= CSGD_TextureManager::GetInstance();
	m_pDI	= CSGD_DirectInput::GetInstance();
	m_pXA	= CSGD_XAudio2::GetInstance();
	m_pTM	= CSGD_TextureManager::GetInstance();

	m_nBackGroundImgID = m_pTM->LoadTexture(	_T("../resources/graphics/ShadowInto.jpg")/*, D3DCOLOR_XRGB(0, 0, 0)*/ );
}

void CIntroState::Exit(void)
{
	if (this->m_nBackGroundImgID != -1)
	{
		this->m_pTM->UnloadTexture(this->m_nBackGroundImgID);
		this->m_nBackGroundImgID = -1;
	}
}

void CIntroState::Update(float fElapsedTime) { }

void CIntroState::Render(void)
{

	m_pTM->Draw(m_nBackGroundImgID, 0, 0, 0.8f, 0.6f, nullptr, 0, 0, 0); 
	m_pD3D->GetSprite()->Flush();
}

bool CIntroState::Input(void)
{
	int key = m_pDI->GetDIKCode();
	if (m_pDI->KeyPressed(key))
	{
		if (key != DIK_RETURN)
		{
		CGame::GetInstance()->AddState(CMainMenuState::GetInstance());
		CGame::GetInstance()->RemoveState(this);
		}
	}
	return true;
}